What will be the output of the following Python code? def a(): try: f(x, 4) finally: print('after f') print('after f?') a()
1.No output
2. after f?
3.error
4.after f
Posted Date:-2022-01-02 12:27:10
An exception is _______
1. an object
2.a special function
3. a standard module
4. a module
Posted Date:-2022-01-02 12:35:26
Compare the following two Python codes shown below and state the output if the input entered in each case is -6? CODE 1 import math num=int(input("Enter a number of whose factorial you want to find")) print(math.factorial(num)) CODE 2 num=int(input("Enter a number of whose factorial you want to find")) print(math.factorial(num))
1. ValueError, NameError
2.AttributeError, ValueError
3.NameError, TypeError
4.TypeError, ValueError
Posted Date:-2022-01-02 12:32:09
Identify the type of error in the following Python codes? Print(“Good Morningâ€) print(“Good night)
1.Syntax, Syntax
2.Semantic, Syntax
3. Semantic, Semantic
4.Syntax, Semantic
Posted Date:-2022-01-02 12:33:54
The error displayed in the following Python code is? import itertools l1=(1, 2, 3) l2=[4, 5, 6] l=itertools.chain(l1, l2) print(next(l1))
1.‘list’ object is not iterator
2.‘tuple’ object is not iterator
3. ‘list’ object is iterator
4. ‘tuple’ object is iterator
Posted Date:-2022-01-02 12:28:11
What happens if the file is not found in the following Python code? a=False while not a: try: f_n = input("Enter file name") i_f = open(f_n, 'r') except: print("Input file not found")
1.No error
2.Assertion error
3.Input output error
4. Name error
Posted Date:-2022-01-02 12:29:48
What will be the output of the following Python code if the input entered is 6? valid = False while not valid: try: n=int(input("Enter a number")) while n%2==0: print("Bye") valid = True except ValueError: print("Invalid")
1.Bye (printed once)
2.No output
3.Invalid (printed once)
4.Bye (printed infinite number of times)
Posted Date:-2022-01-02 12:32:59
What will be the output of the following Python code, if the time module has already been imported? 4 + '3'
1.NameError
2. IndexError
3. ValueError
4. TypeError
Posted Date:-2022-01-02 12:31:02
What will be the output of the following Python code? #generator def f(x): yield x+1 g=f(8) print(next(g))
1.8
2.9
3.7
4.Error
Posted Date:-2022-01-02 12:25:22
What will be the output of the following Python code? def f(x): for i in range(5): yield i g=f(8) print(list(g))
1. [0, 1, 2, 3, 4]
2.[1, 2, 3, 4, 5, 6, 7, 8]
3. [1, 2, 3, 4, 5]
4. [0, 1, 2, 3, 4, 5, 6, 7]
Posted Date:-2022-01-02 12:27:43
What will be the output of the following Python code? def f(x): yield x+1 print("test") yield x+2 g=f(9)
1. Error
2. test
3.test 10 12
4.No output
Posted Date:-2022-01-02 12:26:24
What will be the output of the following Python code? def getMonth(m): if m<1 or m>12: raise ValueError("Invalid") print(m) getMonth(6)
1. ValueError
2. Invalid
3.6
4.ValueError(“Invalidâ€)
Posted Date:-2022-01-02 12:32:33
What will be the output of the following Python code? g = (i for i in range(5)) type(g)
1.class <’loop’>
2.class <‘iteration’>
3.class <’range’>
4.class <’generator’>
Posted Date:-2022-01-02 12:29:09
What will be the output of the following Python code? int('65.43')
1. ImportError
2.ValueError
3.TypeError
4.NameError
Posted Date:-2022-01-02 12:31:35
What will be the output of the following Python code? lst = [1, 2, 3] lst[3]
1.NameError
2.ValueError
3. IndexError
4. TypeError
Posted Date:-2022-01-02 12:30:12
What will be the output of the following Python code? t[5]
1.IndexError
2. NameError
3.TypeError
4.ValeError
Posted Date:-2022-01-02 12:30:36
Which of the following blocks will be executed whether an exception is thrown or not?
1. except
2.else
3.finally
4. assert
Posted Date:-2022-01-02 12:37:09
Which of the following is not a standard exception in Python?
1.NameError
2.IOError
3.AssignmentError
4.ValueError(“Invalidâ€)
Posted Date:-2022-01-02 12:34:58
Which of the following is not an exception handling keyword in Python?
1. try
2.except
3.accept
4.finally
Posted Date:-2022-01-02 12:28:38
Which of the following statements is true?
1.The standard exceptions are automatically imported into Python programs
2.All raised standard exceptions must be handled in Python
3.When there is a deviation from the rules of a programming language, a semantic error is thrown
4.If any exception is thrown in try block, else block is executed
Posted Date:-2022-01-02 12:34:24
_______________ exceptions are raised as a result of an error in opening a particular file.
1.ValueError
2.TypeError
3. ImportError
4.IOError
Posted Date:-2022-01-02 12:35:48